import React, { FC, useEffect } from "react";
import Route from "@routes/index";
import { BrowserRouter } from "react-router-dom";
import moment from "moment";
import "moment/locale/zh-cn";
import "@css/common";
import { RecoilRoot } from "recoil";
import Header from "@components/Header";
import Menu from "@components/Menu";
moment.locale("zh-cn");
const Container:FC = () => {
  useEffect(() => {
    if (!sessionStorage.userInfo) {
      window.location.href = "/login";
    }
  }, []);
  return (
    <div className="container">
      <Menu />
      <main>
        <Route />
      </main>
    </div>
  );
};
const App: FC = () => {
  return (
    <RecoilRoot>
      <Header />
      <BrowserRouter basename="/">
        {window.location.pathname == "/login" ? <Route /> : <Container />}
      </BrowserRouter>
    </RecoilRoot>
  );
};
export default App;
